package cn.theten52.demo.patterns.design.behavior.memento.update1;

/**
 * 备忘录实现类
 *
 * @author wangjin
 * @date 2021/4/4
 */
public class MementoImpl<T extends State> implements Memento<T> {
    private T state;

    @SuppressWarnings("unchecked")
    @Override
    public T get() {
        return (T)(state.clone());
    }

    @Override
    public Memento<T> set(T state) {
        this.state = state;
        return this;
    }
}
